package com.tron.sync.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(name = "tbds.kafka.enable",havingValue = "rabbitmq")
public class AMQPConfig {

    @Bean
    public TopicExchange exchange() {
        // rabbit中exchanges中显示的名称
        return new TopicExchange("OrgUserChangeExchange");
    }


    @Bean
    public Queue queue() {
        // rabbit中queues中显示的名称
        return new Queue("syncService");
    }

    @Bean
    public Binding bindingExchangeMessage( Queue queue, TopicExchange exchange) {
        //匹配规则
        return BindingBuilder.bind(queue).to(exchange).with("OrgUserChangeNotice.#");
    }
}
